package com.peanut.service.impl;

import com.peanut.entity.Channel;
import com.peanut.entity.dto.QueryChannel;
import com.peanut.mapper.ChannelMapper;
import com.peanut.service.ChannelService;
import com.spring.annotation.Autowired;
import com.spring.annotation.Service;

import java.util.List;

@Service
public class ChannelServiceImpl implements ChannelService {
	@Autowired
	private ChannelMapper mapper;
	
	@Override
	public List<Channel> queryChannel(QueryChannel queryChannel) {
		if (queryChannel.getSonChannelType() != null) {
			return mapper.queryBySonChannelType(queryChannel);
		} else {
			return mapper.queryByTopChannelType(queryChannel);
		}
	}
	
	@Override
	public boolean updateById(Channel channelType) {
		return mapper.updateById(channelType) > 0;
	}
	
	@Override
	public boolean add(Channel channelType) {
		return mapper.insert(channelType) > 0;
	}
	
	@Override
	public boolean delete(int id) {
		// 删就删，拉倒
		
		return mapper.deleteById(id) == 1;
	}
}
